<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>SEUIC-终端管理系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="shortcut icon" href="../assets/img/favicon-icon.png" />
    <link rel="stylesheet" href="../assets/css/bootstrap.css">
    <!--[if IE 8]>
    <link rel="stylesheet" href="../assets/css/bootstrapIE8.css">
    <![endif]-->
    <link rel="stylesheet" href="../assets/Datepicke/datepicker.css">
    <link rel="stylesheet" href="../assets/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="../assets/css/bootstrap-responsive.css">
    <link rel="stylesheet" href="../assets/css/formValidation.css"/>
    <link rel="stylesheet" href="../assets/css/seuic.css">
    <script>
        if(localStorage.UserCode==null){
            location.href="./login.html";
        }
    </script>
</head>

<body>
<div class="wrap">
    <div class="main">
        <div class="main-inner">
            <div class="row-fluid div-nav">
                <!-- 主导航 -->
                <div class="col-md-1 global-toggle ">
                    <div class="btn-group hidden">
                        <a class="row-fluid " href="#"><em class="icon-sm arrowLeft"></em></a>
                    </div>
                </div>
                <div class="col-md-11 div-user">
                    <div class="btn-group hidden">
                        <div id="current-time"></div>
                    </div>
                    <!-- 注意:右侧对齐排列顺序是先写的在最右边 -->
                    <div class="btn-group pull-right">
                        <a class="div-user-btn" href="#" onclick="systemExit()"><span class="icon-em logout"></span></a>
                    </div>
                    <div class="btn-group pull-right">
                        <a class="dropdown-toggle div-user-btn" data-toggle="dropdown" href="#" id="log_name">
                            <span class="icon-em op"> </span>&nbsp;
                        </a>
                        <ul class="dropdown-menu">
                            <!--<li class=""><a class="" href="index.html"><span class="icon-sm index"></span> 首页</a></li>-->
                            <li><a id="user_code">用户代码：</a></li>
                            <li><a id="user_name">用户名称：</a></li>
                            <li class="divider"></li>
                            <li class=""><a class="" href="#" id="changePwd"><span class="icon-em edit"></span> 修改密码</a></li>
                        </ul>
                    </div>
                    <div class="btn-group pull-right hidden">
                        <a class="dropdown-toggle div-task" href="#">未完成 <em class="badge" >16</em></a>
                    </div>
                </div>
            </div>
            <div class="row-fluid div-body ">
                <!-- 主窗体 -->
                <div class="row-fluid main-body">
                    <div class="row-fluid clearfix">
                        <div class="col-md-12 column">
                            <ul class="breadcrumb">
                                <li>
                                    首页
                                </li>
                            </ul>
                        </div>
                        <div class="col-md-12 column">
                            <div class="col-md-12 div-page">
                                <div class="col-md-12 div-table" style="height: 464px;">
                                        <table class="table">
                                            <caption>当前用户信息：</caption>
                                            <thead>
                                                <tr>
                                                    <th>&nbsp; 用户代码</th>
                                                    <th>&nbsp; 用户名称</th>
                                                    <th>&nbsp; 登录名称</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td><span id="UserCode"></span></td>
                                                    <td><span id="UserName"></span></td>
                                                    <td><span id="logName"></span></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                </div>
                            </div>
                            <div class="col-md-12 column">
                                <div class="col-md-12 alert alert-success div-alert" id="events-result" data-es="Aquí se muestra el resultado del evento"></div>
                            </div>

                        </div>
                    </div>
                </div>

                <!-- #遮罩层 --->
                <div class="modal fade" id="modal-Template" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <!-- #从模板加载 --->
                </div>
            </div>
        </div>
    </div>
    <div class="fixed">
        <div class="row-fluid div-logo">
            <!-- logo图标 -->
            <a class="row-fluid logo" href="#" style="color:#2DA8D3;font-size: 18px;padding-left: 0.5em;letter-spacing: 6px;font-weight: 600;">终端管理系统</a>
        </div>
        <div class="row-fluid div-menu ">
            <!-- 主菜单 -->
            <div class="row-fluid main-menu" id="panel-root"></div>
        </div>
    </div>
</div>
<script src="../assets/js/jquery-1.11.1.min.js"></script>
<script src="../assets/js/jquery_and_jqueryui.js"></script>
<script src="../assets/js/jquery.cookie.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/Datepicke/bootstrap-datepicker.js"></script>
<script src="../assets/js/formValidation.js"></script>
<script src="../assets/js/framework/bootstrap.js"></script>
<script src="../assets/js/table/bootstrap-table.js"></script>
<script src="../assets/js/jquery.md5.js"></script>
<script src="../assets/js/Chart.js"></script>
<!--<script src="../assets/js/auth.js"></script>-->
<script src="../assets/js/seuic.js"></script>
<script src="../assets/js/placeholderForIE.js"></script>
<script>
    $(function(){
        //获取操作员信息
        $("#UserCode").html(localStorage.UserCode);
        $("#UserName").html(localStorage.UserName);
        $("#logName").html(localStorage.logName);

        $("#user_code").append(localStorage.UserCode);
        $("#user_name").append(localStorage.UserName);
        $("#log_name").append(localStorage.logName);

        //var url = globalUrl+"api/Authority"+"?UserCode="+globalUserCode;
        var url = "../json/menu.json";
        $.ajax({
            data:{},
            type: "get",
            url: url,
            dataType: "json",
            success: function (resp) {
                if(resp)
                {
                    var menu1=resp.data.children;
                    var len1=menu1.length;
                    for(var i=0;i<len1;i++)
                    {
                        var menu2=menu1[i].children;
                        var len2=menu2.length;
                        var htmlStr1='<div class="panel"><a href="#i'+i+'" data-parent="#panel-root" class="nav-header menu-first collapsed" data-toggle="collapse">'+
                                '<span class="'+menu1[i].iconCls+'"></span> <span class="">'+menu1[i].text+
                                '</span> <span class="caret pull-right"></span></a><ul id="i'+i+'" class="nav-list collapse menu-second">';
                        for(j=0;j<len2;j++)
                        {
                            //var htmlStr2='<li><a href="'+menu2[j].url+'"><span class="'+menu2[j].iconCls+' "></span> <span class="">'+
                            var htmlStr2='<li><a href="'+menu2[j].url+'"><span class=" icon-sm dot " ></span>&nbsp;&nbsp;<span class="">'+
                                    menu2[j].text+
                                    '</span></a></li>';

                            htmlStr1 = htmlStr1 + htmlStr2;
                        }
                        htmlStr1 = htmlStr1 + '</ul></div>';
                        $(".main-menu").append(htmlStr1);
                    }
                    $(".main-menu").find(" li a ").on("click",function(e){
                        e.preventDefault();
                        $(".main-menu").find(" li a ").removeClass("menu-second-selected");
                        $(this).addClass("menu-second-selected");
                        var funName=$.trim($(this).text());
                        $.ajax({
                            type: "get",
                            url: $(this).attr("href"),
                            dataType: "html",
                            success: function (result) {
                                $(".main-body").html(result);
                                $(".modal").addClass("dropzone");
                                $('.dropzone').draggable();
                                $(".breadcrumb .active").text(funName);
                                $(".modal").attr("data-backdrop","static")
                            }
                        });
                    });
                    $(".main-menu").find(' a[data-parent="#panel-root"] ').on("click",function(e){
                        e.preventDefault();
                        var obj = $(this).find("span[class*='caret']");
                        var objAll = $(".main-menu").find("span[class*='caret']");
                        var bool = obj.hasClass("rotate");
                        objAll.removeClass("rotate");
                        if(!bool){
                            obj.addClass("rotate") ;
                        }
                    });
                }
                else
                {
                    alert("获取菜单数据为空！");
                }
            },
            error:function(){
                alert("获取菜单数据失败！");
            }
        });

        //修改密码
        $('#changePwd').on("click",function () {

            var url="../assets/tpls/Password_Edit.html";
            getTpls(url,function(resp){
                $("#modal-Template").html(resp);

                $("#UserCode").val($.cookie("Custom-Auth-Name"));
                $("#UserName").val($.cookie("UserName"));

                $('#modal-Template').modal('show');


                $('#validForm')
                        .formValidation()
                        .on('success.form.fv', function(e) {
                            e.preventDefault();
                            var $form = $(e.target);
                            var bv = $form.data('formValidation');
                            // Use Ajax to submit form data
                            e.preventDefault();

                            $('#OldPass').val(hash($('#OldPass').val()));
                            $('#NewPass').val(hash($('#NewPass').val()));
                            $.ajax({
                                type: "POST",
                                data: "",
                                url: globalUrl+"api/Emp?"+$('#validForm').serialize(),
                                dataType: "json",
                                success: function (resp) {
                                    if(resp.result)
                                    {
                                        console.log(resp);
                                        alert("密码修改成功，请重新登录！");
                                        location.href="./login.html";
                                    }
                                    else
                                    {
                                        alert(resp.msg);
                                    }
                                },
                                error:function(){
                                    alert("服务器通信失败，请重试或联系系统管理员！");
                                }
                            });


                        });

            });
        });
    });

</script>
</body>
<object id="NDV_OCX" class="hidden" codebase="ocx/NDV_OCX.ocx#Version=1,0,0,1" classid="CLSID:852c696d-f85b-41cd-8be7-8cf152821bdc"></object>
</html>